{layout name="main"/}
<div class="wrapper wrapper-content animated fadeInUp">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">


                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">一级密码</a>
                        </li>
                        <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">二级密码</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="tab-1" class="tab-pane active">
                            <div class="panel-body">
                                <div class="ibox-content" style=" border:none">
                                    <form method="post" action="" class="form-horizontal m-t" id="editPwd1">
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">旧密码 * </label>
                                            <div class="col-sm-5">
                                                <input type="password" placeholder="请输入之前的密码" class="form-control" name="oldpassword" value="">

                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">新密码 * </label>
                                            <div class="col-sm-5">
                                                <input type="password" placeholder="请输入新密码" class="form-control" name="password" value="">

                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">确认新密码 * </label>
                                            <div class="col-sm-5">
                                                <input type="password" placeholder="请重复输入新密码" class="form-control input-s" name="password_confirm" value="">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">验证码 * </label>
                                            <div class="col-sm-2">
                                                   <input type="text" placeholder="输入4位验证码" class="form-control" name="code" value="">
                                            </div>
                                        </div>
                                         <div class="form-group">
                                            <label class="col-sm-3 control-label"> </label>
                                            <div class="col-sm-2">
                                                    {:captcha_img('index/id/2')}
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <div class="col-sm-4 col-sm-offset-3">
                                                <button class="btn btn-primary" type="button" onclick="changepwd()">保存修改</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div id="tab-2" class="tab-pane">
                            <div class="panel-body">
                             <div class="ibox-content" style=" border:none">
                                    <form method="post" action="" class="form-horizontal m-t" id="editPwd2">
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">旧密码 * </label>
                                            <div class="col-sm-5">
                                                <input type="password" placeholder="请输入之前的密码" class="form-control" name="oldpassword2" value="">

                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">新密码 * </label>
                                            <div class="col-sm-5">
                                                <input type="password" placeholder="请输入新密码" class="form-control" name="password2" value="">

                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">确认新密码 * </label>
                                            <div class="col-sm-5">
                                                <input type="password" placeholder="请重复输入新密码" class="form-control input-s" name="password2_confirm" value="">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">验证码 * </label>
                                            <div class="col-sm-2">
                                                   <input type="text" placeholder="输入4位验证码" class="form-control" name="code" value="">
                                            </div>
                                        </div>
                                         <div class="form-group">
                                            <label class="col-sm-3 control-label"> </label>
                                            <div class="col-sm-2">
                                                    {:captcha_img('index/id/3')}
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <div class="col-sm-4 col-sm-offset-3">
                                                <button class="btn btn-primary" type="button" onclick="changepwd2()">保存修改</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>

                            </div>
                        </div>
                    </div>


                </div>


            </div>
        </div>
    </div>
</div>
<script>
    function changepwd() {
        var postdata = $("#editPwd1").serialize();
        post({
            url: "{$thispageurl}",
            data: postdata+"&setting=1",
            success: function(res) {
                swal({
                    title: 'success',
                    text: res.message,
                    type: "success"
                }, function() {
                    toUrl("{:url('Admin/index/signout')}");
                });
            },
            error: function(error) {
                swal("错误", JSON.parse(error.responseText).message, "error");
            }
        });
    }
    function changepwd2() {
        var postdata = $("#editPwd2").serialize();
        post({
            url: "{$thispageurl}",
            data: postdata+"&setting=2",
            success: function(res) {
                swal({
                    title: 'success',
                    text: res.message,
                    type: "success"
                }, function() {
                    reload();
                });
            },
            error: function(error) {
                swal("错误", JSON.parse(error.responseText).message, "error");
            }
        });
    }
</script>
